﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TrippleGameDAL;

namespace TrippleGameService
{
    public class GameDTO
    {
        public string Matrix { get; set; }
        public int Id { get; set; }
        public string Player1Id { get; set; }
        public string Player2Id { get; set; }
        public string State { get; set; }
        public string Name { get; set; }

        public static GameDTO ConvertFromGame(Game game)
        {
            GameDTO converted = new GameDTO()
            {
                Matrix = game.Matrix,
                Id = game.GameId,
                Player1Id = game.Player1Id.ToString(),
                Player2Id = game.Player2Id.ToString(),
                State = game.State,
                Name = game.Name
            };

            return converted;
        }

        public static List<GameDTO> ConvertAllFromGame(List<Game> games)
        {
            List<GameDTO> convertedGames = new List<GameDTO>(games.Count);

            foreach (var game in games)
            {
                convertedGames.Add(ConvertFromGame(game));
            }
            return convertedGames;
        }

    }
}
